#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int N = 100003; //100005

ll m,n;
ll qmi(ll a,ll b,ll c)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans * a % c;
		a = a * a % c;
		b>>=1;
	}
	return ans;
}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin >> m >> n;
	ll all = qmi(m,n,N);
	ll fail = ((m%N)*qmi(m-1,n-1,N))%N;
	ll ans = (all - fail)%N;
	if(ans < 0)
	{
		ans += N;
		ans %= N;
	} 
	cout << ans << endl;
	return 0;
}
